Skip to content

bugfix: prevent uthread crash by checking coroutine reference before …#2479

Merged
zhuizhuhaomeng merged 11 commits intoopenresty:masterfrom
oowl:fix-uthread-crash
Mar 10, 2026
Merged

bugfix: prevent uthread crash by checking coroutine reference before …#2479
zhuizhuhaomeng merged 11 commits intoopenresty:masterfrom
oowl:fix-uthread-crash

Conversation

@oowl
Copy link
Contributor

@oowl oowl commented Mar 9, 2026

…deletion

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

Copilot AI review requested due to automatic review settings March 9, 2026 15:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent user-thread (uthread) crashes during coroutine cleanup by only deleting threads (and decrementing ctx->uthreads) when the coroutine has a valid Lua registry reference (co_ref != LUA_NOREF).

Changes:

  • Guard ngx_http_lua_del_thread(...) + ctx->uthreads-- with co_ref != LUA_NOREF in multiple uthread termination paths.
  • Adjust uthread cleanup logic to avoid acting on already-unreferenced coroutines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@oowl oowl requested a review from zhuizhuhaomeng March 10, 2026 03:37
@oowl oowl force-pushed the fix-uthread-crash branch from bc02d0c to 6772f99 Compare March 10, 2026 05:20
@oowl oowl force-pushed the fix-uthread-crash branch from 8db38f4 to cbe99ec Compare March 10, 2026 05:46
@zhuizhuhaomeng zhuizhuhaomeng merged commit 4b580ff into openresty:master Mar 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants